<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="//cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>
    <div>
        <div>
            <input type="text" name="" id="input">
            <input type="text" name="" id="input1">
            <button id="btn">添加</button>
        </div>
        <div id="content">
            <ul>
                <li>
                    1
                </li>
                <li>
                    2
                </li>
            </ul>
        </div>
    </div>
    <script>
        $(function () {
            var todos = JSON.parse(localStorage.getItem('todolist')) || [];
            $("#btn").click(function () {
                var inputA = $("#input").val();
                var inputB = $("#input1").val();
                var obj = {
                    "user": inputA,
                    "password": inputB
                }
                todos.push(obj)

                localStorage.setItem('todolist', JSON.stringify(todos))
                console.log(todos)
            })
        })
    </script>
</body>

</html>